<?php require_once('__common.php');
    $no = $_GET['mb_no'];
    $year = $_GET['year'] ? $_GET['year'] : date('Y');
    $month = $_GET['month'] ? $_GET['month'] : date('m');
    $sql = "SELECT * from g4_member WHERE mb_no = $no";
    $res = mysql_query($sql);
    if(mysql_error()) {
        alert('잘못된 호출입니다');
    }
    extract(mysql_fetch_assoc($res));

    $yearSelcted = array($year => 'selected = "selected"');
    $monthSelcted = array($month => 'selected = "selected"');

    $count = 1;
    $sql = "SELECT c.name as coursename, b.name as bookname, c.starttime as time, c.no as courseno FROM course c, book b WHERE teacher = $mb_no AND c.bookcode = b.no AND c.year = $year AND c.month = $month";
    $res = mysql_query($sql);
    $data = array();
    $i = 1;
    while($temp = mysql_fetch_assoc($res)) {
        if($temp['time'] > 12) {
            $div[0] = $div[1] = '오후';
            $temp['time'] = $temp['time'] - 12;
            $temp['endtime'] = $temp['time']+1;
            if($temp['endtime'] > 12) {
                $div[] = '오전';
            } 
        } else {
            $div[0] = $div[1] = '오전';
            $temp['endtime'] = $temp['time']+1;
            if($temp['endtime']  > 12) {
               $div[1] = '오후'; 
            }
        }
            $temp['time'] = $div[0]. " ".$temp['time']++.'시~'.$div[1]." ".$temp['time'].'시';
            $temp['count'] = $i++;
        $data[] = $temp;

    }

    $yearSelect = '';
    for($i = 2008; $i <= date('Y'); $i++){ 
            $yearSelect .= "<option value=\"$i\" $yearSelcted[$i]>{$i}년</option>";

    }
    $monthSelect = '';
        for($i = 1; $i <= 12; $i++){ 
                $monthSelect .= "<option value=\"$i\" $monthSelcted[$i]>{$i}월</option>";

        }
    $tpl->print_('basic');
